import { API } from "@/utils/api"
import service from "@/utils/https"

// 新增商品类别
export const addProductCategory = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/save-product-category',
		method: 'post',
		data: params,
	})
}

// 编辑商品类别
export const editProductCategory = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/update-product-category',
		method: 'post',
		data: params,
	})
}

// 删除商品类别
export const deleteProductCategory = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/delete-product-category',
		method: 'post',
		data: params,
	})
}

// 查询商品类别列表
export const getProductCategoryList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/find-product-category-list',
		method: 'post',
		data: params,
	})
}

// 查询商品列表
export const findProductList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/find-product-list',
		method: 'post',
		data: params,
	})
}

// 查询商品类别详情
export const getProductCategoryDetail = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/get-product-category-detail',
		method: 'get',
		params,
	})
}

// 查询商品类别-无分页
export const getProductCategory = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/get-product-category',
		method: 'get',
		params,
	})
}

// 新增商品
export const addProduct = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/save-product',
		method: 'post',
		data: params,
	})
}

// 编辑商品
export const updateProduct = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/update-product',
		method: 'post',
		data: params,
	})
}

// 商品上下架
export const updateProductPublishStatus = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/update-product-publish-status',
		method: 'post',
		data: params,
	})
}

// 删除商品
export const deleteProduct = (params: { spuId: number }): Promise<API.responseType> => {
	return service({
		url: `system/rest/product/delete-product-by-id/${params.spuId}`,
		method: 'post'
	})
}

// 查询商品详情
export const getProductDetail = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/product/get-product-detail',
		method: 'get',
		params,
	})
}

/**
 * 查询订单列表
 */
export const findOrderProductList = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/order/product/find-order-product-list',
		method: 'post',
		data: params,
	})
}

/**
 * 订单发货
 */
export const orderDelivery = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/order/product/order-delivery',
		method: 'post',
		data: params,
	})
}

/**
 * 订单改价
 */
export const modifyOrderAmount = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system/rest/order/product/modify-order-amount',
		method: 'post',
		data: params,
	})
}

/**
 * 订单退款
 */
export const refundAmount = (params?: object): Promise<API.responseType> => {
	return service({
		url: 'system//rest/order/order-refund',
		method: 'post',
		data: params,
	})
}
